﻿namespace ClientDemo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            using (var client = new Consul.ConsulClient(c => { c.Address = new Uri("http://127.0.0.1:8500"); }))
            {

                var cs = client.Agent.Services().Result.Response;

                HttpClient httpClient = new HttpClient();

                foreach (var item in cs)
                {
                    Console.WriteLine($"key:{item.Key},value:{item.Value.Service},Address:{item.Value.Address}");
                    var url = $"http://{item.Value.Address}:{item.Value.Port}/api/product";
                    var str = httpClient.GetStringAsync(url).Result;

                    Console.WriteLine($"url:{url}，result:" + str);
                }

            }

            Console.WriteLine("Hello, World!");
        }
    }
}